char* lcp(char* str1, char* str2)
{
    int length = (strlen(str1) < strlen(str2)) ? strlen(str1) : strlen(str2);
    int index = 0;

    while (index < length && str1[index] == str2[index]) {
        index++;
    }

    char* result = (char*)malloc((index + 1) * sizeof(char));
    strncpy(result, str1, index);
    result[index] = '\0';

    return result;
}


char * longestCommonPrefix(char ** strs, int strsSize){
    if(strsSize==0)
        return "";
    char *prefix=strs[0];
    int count = strsSize;
    for (int i = 1; i < count; i++) {
        prefix = lcp(prefix, strs[i]);

        if (strlen(prefix) == 0) {
            break;
        }
    }
    return prefix;
}